﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static OpenCvSharp_ImageRecognition.Servers;

namespace OpenCvSharp_ImageRecognition
{
    class Program
    {
        async static Task Main(string[] args)
        {
            string pngPath = @"J:\VS总项目文件夹\电子测试技术预研\图像识别技术\OpenCvSharp_ImageRecognition\bin\Debug\图片识别\4.png";
            IOpenCvSharp4_图像识别接口 OpenCvSharp = new Servers();
            Stopwatch stopwatch = new Stopwatch();
            //Time elapsed: 00:00:04.9739042 多线程预计时长   //Time elapsed: 00:00:10.0552281 单线程预计时长   
            // 开始计时
            stopwatch.Start();
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine($"{i}---开始识别");
                Console.WriteLine($"**********");
                OpenCvSharp.Prioritylevel(Signal.Signal_2);
                Task<Tuple<bool, string[]>> aaa = OpenCvSharp.ImageRecognitionAsync(pngPath, Mode.wifi, DeviceType.平板, 最大匹配值: 0.999999, log: true);
                Tuple<bool, string[]> result = await aaa;
                if (result.Item1)
                {
                    string[] results = result.Item2;
                    // 停止计时
                    stopwatch.Stop();
                    // 输出运行时间
                    Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
                    Console.WriteLine("OK " + "模式：" + results[0] + "  信号格：" + results[1]);
                }
                else
                {
                    // 停止计时
                    stopwatch.Stop();

                    // 输出运行时间
                    Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);


                }
            }

            Console.ReadKey();
        }
    }
}
